package com.atnjupt.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author Wizarder
 * @create 2022-03-30 21:06
 * 反向引用和捕获
 */
public class RegDemo2 {
    public static void main(String[] args) {
        //个位和千位相同，百位和十位相同
        String content = "asdasdasdasdas67761-333444555jkfhgkdfsh";
        //正则内部的反向捕获 用\\分组号
//        String reg = "(\\d)(\\d)\\2\\1";
        String reg = "\\d{5}-(\\d)\\1{2}(\\d)\\2{2}(\\d)\\3{2}";
        Pattern compile = Pattern.compile(reg);
        Matcher matcher = compile.matcher(content);

        while (matcher.find()) {
            System.out.println("找到了：" + matcher.group(0));
        }

    }
}
